package GameLogic

import (
	"git.oschina.net/yangdao/GameLib/Unit"
	"git.oschina.net/yangdao/SGLisp"
	"git.oschina.net/yangdao/SGLisp/parse"
)

type Effect_Damage struct {
	*Unit.Effect
}

func CreateEffectDamage(args []parse.Node, context *SGLisp.Context) Unit.IEffect {
	newEffect := &Effect_Damage{
		Effect: &Unit.Effect{},
	}
	newEffect.Name = args[0].(*parse.SymbolNode).Val
	return newEffect
}
func (this *Effect_Damage) Base() *Unit.Effect {
	return this.Effect
}

func (this *Effect_Damage) OnLoad(srcAbility Unit.IAbility, srcUnit Unit.IUnit, otherArgs ...interface{}) {
	this.Effect.OnLoad(srcAbility, srcUnit, otherArgs)
}

func (this *Effect_Damage) OnExec(context *SGLisp.Context) {
	if this.DstUnit.Base().IsDie || this.DstUnit.Base().IsInvincible {
		return
	}
	atkNumber := this.SrcUnit.Base().Attack()
	this.DstUnit.Base().SetHP(this.DstUnit.Base().HP() - atkNumber)
}

/*
  Unit
    Effect

*/
